{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def findWords(self, words):\n",
    "        \"\"\"\n",
    "        :type words: List[str]\n",
    "        :rtype: List[str]\n",
    "        \"\"\"\n",
    "        row = [set('qwertyuiop'), set('asdfghjkl'), set('zxcvbnm')]\n",
    "        ret = []\n",
    "        \n",
    "        intersection = lambda x : x & s_w\n",
    "        \n",
    "        for w in words:\n",
    "            s_w = set(w.lower())\n",
    "            inter = list(map(lambda x: x & s_w, row))\n",
    "\n",
    "            if s_w in inter:\n",
    "                ret.append(w)\n",
    "                \n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Alaska', 'Dad']"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.findWords([\"Hello\",\"Alaska\",\"Dad\",\"Peace\"])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
